package com.hx.hospital.mapper;

import com.hx.hospital.pojo.ClinicCard;
import com.hx.hospital.pojo.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.type.JdbcType;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

public interface ClinicCardMapper extends Mapper<ClinicCard> {

    @Results(id = "ClinicCardResult",
            value={@Result(property = "id", column = "id", jdbcType = JdbcType.BIGINT),
                    @Result(property = "name", column = "name", jdbcType = JdbcType.VARCHAR),
                    @Result(property = "card", column = "card", jdbcType = JdbcType.VARCHAR),
                    @Result(property = "idCard", column = "id_card", jdbcType = JdbcType.VARCHAR),
                    @Result(property = "cardType", column = "card_type", jdbcType = JdbcType.VARCHAR),
                    @Result(property = "phone", column = "phone", jdbcType = JdbcType.VARCHAR),
                    @Result(property = "relationship", column = "relationship", jdbcType = JdbcType.INTEGER),
                    @Result(property = "address", column = "address", jdbcType = JdbcType.VARCHAR),
                    @Result(property = "userId", column = "user_id", jdbcType = JdbcType.BIGINT),
                    @Result(property = "created", column = "created", jdbcType = JdbcType.DATETIMEOFFSET),
                    @Result(property = "defaultPeople", column = "default_people", jdbcType = JdbcType.VARCHAR)})
    @Select("select id,card,name,phone,relationship,user_id,created,address,card_type,id_card,default_people from clinic_card where user_id=#{userId}")
    public List<ClinicCard> queryByUserId(@Param("userId") Long userId);
}
